package org.cangkuguanli.zhuyaohui.mapper;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.cangkuguanli.zhuyaohui.bean.ShoppingCart;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    @Select("select * from shopping_cart where user_id=#{user_id} and is_deleted=0")
    List<ShoppingCart> findByUserId(String userId);

    @Insert("insert into shopping_cart values(null,{user_id},1,#{book_id},0)")
    static void add(ShoppingCart sc) {

    }

    @Update("update shopping_cart set number=number+#{number} where user_id=#{user_id} and book_id=#{book_id}")
    static void update(ShoppingCart sc) {

    }


    @Update("shopping_cart set is_deleted=1 where user_id=#{user_id} and book_id=#{book_id}")
    void remove1(ShoppingCart sc);
    @Update("shopping_cart set is_deleted=1 where user_id=#{user_id} ")
    void remove2(ShoppingCart sc);

}

